package interview;

public class Leetcode_面试题_0107 {
    public void rotate(int[][] matrix) {
        //对角线翻转
        int n = matrix.length;
        for (int i = 0; i < n - 1; i++) {
            for (int j = i; j < n; j++) {
                int t = matrix[i][j];
                matrix[i][j] = matrix[j][i];
                matrix[j][i] = t;
            }
        }
        // 水平翻转
        int mid = n >> 1;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < mid; j++) {
                int t = matrix[i][j];
                matrix[i][j] = matrix[i][n - 1 - j];
                matrix[i][n - 1 - j] = t;
            }
        }
    }

    public static void main(String[] args) {

    }
}
